<%@page import="com.hnas.sys.service.system.dto.DTOUser"%>
<%@page import="com.hnas.sys.core.util.UserUtils"%>
<%@page import="java.util.Calendar"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="keywords" content="" />
		<meta name="description" content="" />
		<title>电子卡后台管理系统</title>
		<!--[if IE 6]>
		<script src="script/iepng.js" type="text/javascript"></script>
		<![endif]-->
		<link href="${pageContext.request.contextPath }/static/common/style/basic.css" rel="stylesheet" type="text/css" />
		<link href="${pageContext.request.contextPath }/static/common/style/index.css" rel="stylesheet" type="text/css" />
		<link href="${pageContext.request.contextPath }/js/jqueryui/css/cupertino/jquery-ui.css" rel="stylesheet">
		<link href="${pageContext.request.contextPath }/static/css/bootstrap-datepicker.css" rel="stylesheet">
		 <link  href="${pageContext.request.contextPath  }/static/common/style/dialog.css"  rel="stylesheet" type="text/css"/>
		<link  href="${pageContext.request.contextPath  }/static/common/style/flexselect.css"  rel="stylesheet" type="text/css"/>
		
		<style>
		.editFm tr{
	      height:35px;
	    }
	    .editFm input[type="text"]{
	      border: #dcdbdb 1px solid;
	      height: 26px;
	      width: 200px;
	      border-radius: 3px;
	      font-family: Microsoft YaHei; 
	    }
		</style>
		
		<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/jquery-1.10.2.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/util.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/basic.js"></script>
	
	<script src="${pageContext.request.contextPath }/js/jqueryui/js/jquery-ui.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/js/ajaxfileupload.js"></script>
	<script src="${pageContext.request.contextPath }/js/jquery.corner.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/jquery.ui.datepicker-zh-CN.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/static/common/script/jquery.dialog.js"></script>
     <script type="text/javascript" src="${pageContext.request.contextPath }/static/common/script/jquery.nav.js"></script>
      <script type="text/javascript" src="${pageContext.request.contextPath }/static/common/script/liquidmetal.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/static/common/script/jquery.flexselect.js"></script>
   <script type="text/javascript">
(function($){ 

    $.fn.UIdialog = $.fn.dialog; /* 把jquery-ui的dialog另存为UIdialog */ 

})(jQuery)
</script>

	<decorator:head/>
	</head>
<body>
	<%
		DTOUser user = null;
		String name = "";
		try{
			user = UserUtils.getCurrentUser();
			 if(user!=null) {
			 	name = user.getName();
			 }
		}catch(Exception ex){
				
		}
	%>
	<div class="topBar">
		<div class="w_1200a tr">
			<ul class="topList">
				<%if (name!=""){%>
					<li><a href="#">您好，<%=name %></a></li>
					<li><a href="#" id="updatePass" name="updatePass">修改密码</a></li> 
					<li><a href="${pageContext.request.contextPath }/logout">退出</a></li>
					<%}else{%>
					<li><a href="${pageContext.request.contextPath }/login.jsp">请登录</a></li>
					<%}%>
				
				<li><a href="${pageContext.request.contextPath }/contact">联系我们</a></li>
			
			</ul>
		</div>
	</div>

	<!-- 标记(logo)区域 -->
	
	<!-- end 标记(logo)区域 -->
	<!-- 主导航 -->
	
	<!-- end 主导航 -->
	<!-- 二级页面banner -->
	
	<!-- end 二级页面banner -->
	<div class="container">
		<div class="grid_c2_s4c20 cf">
			<div class="col_main">
			     <div class="main_wrap cf">
				 <!-- 右侧 -->
					<decorator:body />
				</div>
			</div>
			<!-- end 右侧 -->
			
			<div class="col_sub">
				<!-- 左侧 -->
				<div class="menuL">
					<%@include file="/WEB-INF/page/common/inc_menu.jsp" %>	
				</div>
		    </div>
		    
		    <!-- end 左侧 -->
				
		</div>
	</div>
	<div class="editDataDiv" id="editPassDIV" title="修改密码" style="display: none;" >
	<form action="#" id="editPassFm" method="post" name="editPassFm" class="editFm">
		<table id="tranInfo_add_table" class="tb_style02" cellpadding="0" cellspacing="0">
			<tr><td width="25%" align="right"> 
 					<label>旧密码：</label>  
 				</td>
 				<td><input type="password" id="oldPass" name="oldPass" class="input_style2"  />
 				<font color="red">*</font>
 				</td>
 			</tr>
			<tr><td width="25%" align="right"> 
 					<label>新密码：</label>  
 				</td>
 				<td><input type="password" id="newPass" name="newPass" class="input_style2" />
 				<font color="red">*</font>
 				</td>
 			</tr>
 			<tr><td width="25%" align="right"> 
 					<label>确认新密码：</label>  
 				</td>
 				<td><input type="password" id="newcfPass" name="newcfPass" class="input_style2" />
 				<font color="red">*</font>
 				</td>
 			</tr>
 			
			<tr>
      			<td colspan="2">
          			<p class="validateTips_deal" align="center"></p>
      			</td>
    		</tr>
		</table>
		
	</form>
	</center>
</div>
	<!-- 站点信息 -->
	<div class="footBar">
		<div class="w_1200a cf">
			
			<div class="copy">琼ICP备21321321号 Copy<em>&copy;</em>2015  www.yktg.com All Right Reserved</div>
		</div>
	</div>
	<!-- end 站点信息 -->
	
		<script>
		(function() {
		   $.ajax({
                 url: '${pageContext.request.contextPath}/frontend/cart/getcount', // 每个页签自定义属性，获取ajax请求url
                 method: 'post',
				async: false,
                 data:  {"userID":0},
                 dataType: 'json',
                 success: function(data) {
                         $(".ci-count").text(data+"件");
                 }
             });
		  
		     $.ajax({
                 url: '${pageContext.request.contextPath}/frontend/product/searchProductTypes', // 每个页签自定义属性，获取ajax请求url
                 method: 'post',
				async: false,
                 data: '',
                 dataType: 'json',
                 success: function(respond) {
                       var htmlstr="";
                     for (var i = 0; i < respond.length; i++) {
                        
                         htmlstr = htmlstr+'<li><a href="${pageContext.request.contextPath }/frontend/product/searchProducts?productType='+respond[i].id+'">'+respond[i].productTypeName+'</a></li>';
                         
                     }
                     $("#menProductTYpe").html(htmlstr)
                   
                 }
             });

             
			var menu = function() {
				var pDom = $('.menuL_list');
				var lis = pDom.find('li');
				pDom.find('.levelF').attr({
					'href': 'javascript:void(0)'
				}).on('click', function() {
					var _this = $(this).parent();
					if (_this.hasClass('on')) {
						_this.removeClass('on');
					} else {
						lis.removeClass('on');
						_this.addClass('on');
					}
					sessionStorage.openRow = $(this).parent("li").attr("value");
				});
				
				if(sessionStorage.openRow > 0){
					$(pDom).find('li:nth-child('+sessionStorage.openRow+')').addClass('on').children('div').show();
			    }
			};
			menu();
			function doSubmitHead(){
		         var f = document.searchHeadForm;
		         f.submit();
	       };
	    
	//绑定时间控件
	$('.input_date02').each(function() {  
     $(this).attr("id", ++$.datepicker.uuid).removeClass("hasDatepicker").datepicker({  
         dateFormat:'yy-mm-dd',
		  changeYear: true,
	      changeMonth: true,
	      yearRange: "1900:2049"
       });  
    });
//绑定时间控件
	$('.input_date').each(function() {  
     $(this).attr("id", ++$.datepicker.uuid).removeClass("hasDatepicker").datepicker({  
         dateFormat:'yy-mm-dd',
		  changeYear: true,
	      changeMonth: true,
	      yearRange: "1900:2049"
       });  
    });
    $('.input_date1').each(function() {  
     $(this).attr("id", ++$.datepicker.uuid).removeClass("hasDatepicker").datepicker({  
         dateFormat:'yy-mm-dd',
		  changeYear: true,
	      changeMonth: true,
	      yearRange: "1900:2049"
       });  
    });
		})();
		</script>
	<script type="text/javascript">
     $(document).ready(function () {
         $("select[class*=flexselect]").flexselect();

     });
      /** 添加 **/	 
	$("#updatePass").click(function(){
		//tips.text("").removeClass("ui-state-highlight");
		$("#oldPass").val("");
		$("#newPass").val("");
	    $("#newcfPass").val("");
		$("#editPassDIV").UIdialog("open");
	});
	$("#editPassDIV").UIdialog({
		autoOpen : false,
		bgiframe: true, 
		height : 350,
		width : 450,
		modal : true,
		resizable :false,
       hide: '',
        show:'',
        zIndex:1000,
		buttons : {
			"保 存" : function() {
				var bValid = doValidPass();
                 
				if(bValid){
					var url = '${pageContext.request.contextPath}/backend/system/userManager/updatePass';
					$.ajax({
						url:url,
						type: 'POST',
						data: $("#editPassFm").serialize(),
							
						error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert('扣款异常。' + textStatus + "/" + errorThrown);
						 $.dialog.alert({title:"修改密码",content:"修改密码异常"});
						},
						success: function(data){
							if(data.result==1) {
								$("#editPassDIV").UIdialog("close");
							    $.dialog.alert({title:"修改密码",content:"修改密码成功"});
							
							} else {
								$.dialog.alert({title:"修改密码",content:"修改密码失败："+ data.errorMessage});	
							}
						}
					});  
				}
			},
			"取 消" : function() {
				$("#editPassDIV").UIdialog("close");		
			}
		},
		close : function() {
			//allFields.val("").removeClass("ui-state-error");
		}
	});
	function doValidPass(){
		
		var oldPass = $("#oldPass");
		var newPass = $("#newPass");
		var newcfPass = $("#newcfPass");
		if (isNull(oldPass.val()))
		{
			$.dialog.alert({title:"修改密码",content:"旧密码不能为空！",objCtrl:"#oldPass"});
			oldPass.trigger("focus");
			return false;
		}
		if (isNull(newPass.val()))
		{
			$.dialog.alert({title:"修改密码",content:"新密码不能为空！",objCtrl:"#newPass"});
			newPass.trigger("focus");
			return false;
		}
		if (isNull(newcfPass.val()))
		{
			$.dialog.alert({title:"修改密码",content:"确认新密码不能为空！",objCtrl:"#newcfPass"});
			newcfPass.trigger("focus");
			return false;
		}
		var pattern = /[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/g;
		if(!pattern.test(newPass.val())||newPass.val().length<8){
			$.dialog.alert({title:"修改密码",content:"密码为8位及以上并且包含字母和数字！",objCtrl:"#newPass"});
			return false;
		}
		if(newPass.val()!=newcfPass.val()){
		  $.dialog.alert({title:"修改密码",content:"确认新密码与新密码不一致！",objCtrl:"#newcfPass"});
		  newcfPass.trigger("focus");
		   return false;
		}
		return true;
	}
    </script>
	
</body>
</html>